package com.danger.Activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.ViewById;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@EActivity(R.layout.activity_thrid)
public class ThridActivity extends AppCompatActivity {

    @ViewById
    ListView listView;
    private List<Map<String, Object>> list = new ArrayList<>();

    @AfterViews
    public void initListView() {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("name", "danger");
        Map<String, Object> map2 = new HashMap<>();
        map2.put("name", "rong");
        Map<String, Object> map3 = new HashMap<>();
        map3.put("name", "feng");
        list.add(map1);
        list.add(map2);
        list.add(map3);
        SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.listview_item, new String[]{"name"}, new int[]{R.id.item_textView});
        listView.setAdapter(adapter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @ItemClick(R.id.listView)
    public void itemClick(Map<String, Object> map) {
        Toast.makeText(this, "点击了" + map.get("name"), Toast.LENGTH_SHORT).show();
    }
}
